﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Dart
{
    public partial class FormDartNew : FormDart
    {
        DartGame dartGame;
        DartBoard dartsBoard;
        private List<string> playerNames = new List<string>();
        
        public FormDartNew()
        {
        }

        public FormDartNew(Boolean isNewForm)
        {
            InitializeComponent();
            this.dartGame = new DartGame(this);
            this.playerNames.Add("");
            this.playerNames.Add("Andrea");
            this.playerNames.Add("Andreas");
            this.playerNames.Add("Gast 1");
            this.playerNames.Add("Gast 2");
            this.playerNames.Add("Gregor");
            this.playerNames.Add("Jens");
            this.playerNames.Add("Sebastian");
            this.playerNames.Add("Stephan");
            this.playerNames.Add("Norman");
            this.playerNames.Sort();
            comboBoxPlayer.DataSource = this.playerNames;

            this.buttonStart.Enabled = false;

            dartsBoard = new DartBoard(this);
        }

        private void FormTest_Load(object sender, EventArgs e)
        {
            dartGame.SetGame(DartGame.GAME_501);
            dartGame.SetMode(DartGame.MODE_COUNT_DOWN);
            dartGame.SetOptionIn(DartGame.OPTION_IN_SINGLE);
            dartGame.SetOptionOut(DartGame.OPTION_OUT_DOUBLE);

            dartGame.RefreshGameDisplay();
        }

        private void comboBoxPlayer_SelectedIndexChanged(object sender, EventArgs e)
        {
            String name = this.comboBoxPlayer.Text;
            if (name != "" && this.dartGame.GetPlayerCount() < 8)
            {
                this.dartGame.AddPlayer(name, this.dartGame.GetGameScore());
            }

            if (this.dartGame.GetPlayerCount() > 0)
            {
                this.buttonStart.Enabled = true;
            }

        }

        private void bEENDENToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void buttonStart_Click(object sender, EventArgs e)
        {
            this.comboBoxPlayer.Enabled = false;
            dartsBoard.Show(this);
        }

    }
}